package web.blogsphere.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import web.blogsphere.interceptor.LogInterceptor;

import java.util.Arrays;
import java.util.List;

/**
 * @ClassName WebConfig
 * @Description 配置Web相关的设置 -> 拦截器, 资源处理器
 * @Author ZJX
 * @Date 2024/9/4 18:30
 * @Version 1.0
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private LogInterceptor logInterceptor;

    private final List excludes =  Arrays.asList(
            "/**/*.html",
            "/blog-editormd/**",
            "/css/**",
            "/js/**",
            "/pic/**",
            "/user/login",
            "/favicon.ico"
    );

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(logInterceptor).addPathPatterns("/**").excludePathPatterns(excludes);
    }
}
